/*=====================================================================================================================
 * 
 * Repository path:     $HeadURL: http://gpstrk.googlecode.com/svn/tags/radio_tests_ok_31.01.2013/src/nmea/nmea_gpvtg.c $
 * Last committed:      $Revision: 42 $
 * Last changed by:     $Author: vladislav.gyurov@gmail.com $
 * Last changed date:   $Date: 2013-01-22 22:32:21 +0000 (Tue, 22 Jan 2013) $
 * ID:                  $Id: nmea_gpvtg.c 42 2013-01-22 22:32:21Z vladislav.gyurov@gmail.com $
 *
 *===================================================================================================================*/
// $GPVTG
// Track Made Good and Ground Speed.
// 
// eg1. $GPVTG,360.0,T,348.7,M,000.0,N,000.0,K*43
// eg2. $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K
// 
// 
// 054.7,T      True track made good
// 034.4,M      Magnetic track made good
// 005.5,N      Ground speed, knots
// 010.2,K      Ground speed, Kilometers per hour
// 
// 
// eg3. $GPVTG,t,T,,,s.ss,N,s.ss,K*hh
// 1    = Track made good
// 2    = Fixed text 'T' indicates that track made good is relative to true north
// 3    = not used
// 4    = not used
// 5    = Speed over ground in knots
// 6    = Fixed text 'N' indicates that speed over ground in in knots
// 7    = Speed over ground in kilometers/hour
// 8    = Fixed text 'K' indicates that speed over ground is in kilometers/hour
// 9    = Checksum
// The actual track made good and speed relative to the ground.
// 
// $--VTG,x.x,T,x.x,M,x.x,N,x.x,K
// x.x,T = Track, degrees True 
// x.x,M = Track, degrees Magnetic 
// x.x,N = Speed, knots 
// x.x,K = Speed, Km/hr

/*=====================================================================================================================
 * Body Identification  
 *===================================================================================================================*/
#ifdef __NMEA_GPVTG_C
    #error "!!! FileName ID. It should be Unique !!!"
#else
    #define __NMEA_GPVTG_C
#endif

/*=====================================================================================================================
 * Included files to resolve specific definitions in this file
 *===================================================================================================================*/
#include "nmea_gpvtg.h"


/*=====================================================================================================================
 * Local constants
 *===================================================================================================================*/
#define cVTG_FixStatusIndex     8    
#define cVTG_SpeedIndex         6





/*=====================================================================================================================
 * Local macros
 *===================================================================================================================*/

/*=====================================================================================================================
 * Local types
 *===================================================================================================================*/

/*=====================================================================================================================
 * Local data
 *===================================================================================================================*/

/*=====================================================================================================================
 * Constant Local Data
 *===================================================================================================================*/

/*=====================================================================================================================
 * Constant exported data                                                     
 *===================================================================================================================*/

/*=====================================================================================================================
 * Exported Data
 *===================================================================================================================*/

/*=====================================================================================================================
 * Local Functions Prototypes
 *===================================================================================================================*/


/*=====================================================================================================================
 *
 *                                  E X P O R T E D    F U N C T I O N S
 *
 *===================================================================================================================*/
/*=====================================================================================================================
 * Parameters: void
 *
 * Return: void
 *
 * Description: 
 *===================================================================================================================*/
tGpsMask NMEAVtg_Decoder(U8 *pu8GpsField[], tNMEA_GPS_Data* GpsData, tGpsMask GpsStat)
{
    tGpsMask tGpsMaskLocal = GpsStat;
    U8 *pu8Char;

    if(*pu8GpsField[cVTG_FixStatusIndex] == 'A')
    {
        // get speed in meters
        pu8Char = (U8*)strchr((const char *)&pu8GpsField[cVTG_SpeedIndex], '.');
        memcpy(GpsData->AX25_GPS_Data.u8Speed, pu8Char, sizeof(GpsData->AX25_GPS_Data.u8Speed));
#if !defined(SMART_BEACONING_DEBUG)
        GpsData->u16GpsSpeed = atoi((const char*)pu8Char);
#endif
    }

    return tGpsMaskLocal;
}


/*=====================================================================================================================
 *                                                                            
 *                                     L O C A L    F U N C T I O N S                   
 *                                                                            
 *===================================================================================================================*/
/*=====================================================================================================================
 * Parameters: void
 *
 * Return: void
 *
 * Description: 
 *===================================================================================================================*/

